Skip to content

Conversation

@donald
Copy link
Collaborator

@donald donald commented Jun 21, 2026

Attempt to run startstop commands inside a user service unit. First make sure that a user service manager is running ("systemctl start user@UID") then start the startstop from this service manager as a transient service ("systemd-run --user").

It that doesn't seem to work, fall back to the previous ("su -c ... &") mechanism.

Running the startstop commands as a user service unit has the advantage that the execution environment of the startstop command is disconnected from the execution environment of the process calling mxtstartup.

Additionally, the startstop command can use the service manager to manage its own services:

#! /usr/bin/bash
set -e

case $1 in
    start)
        systemd-run --user --unit sleeper --same-dir sleep infinity
        ;;
    stop)
        systemctl --user stop sleeper
        ;;
    *)
        echo "usage: $0 {start|stop}" >&1
        exit 1
        ;;
esac

Output of the startup script and additional services goes to the journal and is visible to the user. Note, that this is not true for some old accounts which have a UID < 1000 which are regarded system users by journald systemd and don't get an individual journal log file with an acl on it to give the user read access.

Attempt to run startstop commands inside a user service unit. First
make sure that a user service manager is running ("systemctl start
user@UID") then start the startstop from this service manager as a
transient service ("systemd-run --user").

It that doesn't seem to work, fall back to the previous ("su -c ... &")
mechanism.

Running the startstop commands as a user service unit has the advantage
that the execution environment of the startstop command is disconnected
from the execution environment of the process calling mxtstartup.

Additionally, the startstop command can use the service manager to
manage its own services:

    #! /usr/bin/bash
    set -e

    case $1 in
        start)
            systemd-run --user --unit sleeper --same-dir sleep infinity
            ;;
        stop)
            systemctl --user stop sleeper
            ;;
        *)
            echo "usage: $0 {start|stop}" >&1
            exit 1
            ;;
    esac

Output of the startup script and additional services goes to the journal
and is visible to the user. Note, that this is not true for some old
accounts which have a UID < 1000 which are regarded system users by
journald systemd and don't get an individual journal log file with an
acl on it to give the user read access.
Sign in to join this conversation on GitHub.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant